package br.com.webcrm.view;

import java.util.List;

import br.com.webcrm.model.QuestResposta;

@SuppressWarnings("serial")
public class QuestRespostaDataModel extends PrimeDataModel<QuestResposta>{
	
	public QuestRespostaDataModel() {
	}

	public QuestRespostaDataModel(Object data) {
		super(data);
	}

	@SuppressWarnings("unchecked")
	@Override
    public QuestResposta getRowData(String rowKey) {
        //In a real app, a more efficient way like a query by rowKey should be implemented to deal with huge data
        
        List<QuestResposta> respostas = (List<QuestResposta>) getWrappedData();
        
        for(QuestResposta resposta : respostas) {
        	String id = ""+resposta.getIdResposta();
            if(id.equals(rowKey))
                return resposta;
        }
        
        return null;
    }

    @Override
    public String getRowKey(QuestResposta resposta) {
        return ""+resposta.getIdResposta();
    }

}
